import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import './plugins/element.js'

//导入全局样式
import '../src/assets/css/global.css'

// // 导入字体图标
//导入样式
import './assets/css/fonts/iconfont.css'

//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 富文本编辑器

// 导入axios

import axios from 'axios'

import TreeTable from 'vue-table-with-tree-grid'
//  progress 进程条
import NProgress from 'nprogress'




// 配置axios

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

// 给VUE原型的$http赋值

axios.interceptors.request.use(config => { //创建拦截器,
    // 显示NProgress进度条
    NProgress.start()
    // console.log(config);
    config.headers.authorization = window.sessionStorage.getItem('token')
    return config;
})
//隐藏NProgress进度条
axios.interceptors.response.use(config => {
    NProgress.done()
    return config
})

Vue.prototype.$http = axios

Vue.config.productionTip = false

// 应用全局富文本
Vue.use(VueQuillEditor)

Vue.component('tree-table', TreeTable)


Vue.filter('dateFormat', function (originVal) {
    const dt = new Date(originVal) //创建名为DT的函数,并向里面传参
    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDay() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getSeconds() + '').padStart(2, '0')
    const ss = (dt.getMinutes() + '').padStart(2, '0')
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`

})
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')